package br.com.caelum.vraptor.controller;

import java.util.List;

import javax.inject.Inject;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.anotations.Restrito;
import br.com.caelum.vraptor.dao.TurmaDAO;
import br.com.caelum.vraptor.entidades.Turma;

@Controller
public class TurmaController {

	@Inject
	private TurmaDAO dao;
	@Inject
	private Result result;
	@Restrito
	public void adicionar(){
		
	}
	@Restrito
	public void salvar(Turma turma){
		dao.save(turma);
		result.redirectTo(this).adicionar();
	}
	public List<Turma> lista(){
		return dao.find();
	}
	@Restrito
	public void delete(Integer id){
		Turma turma = dao.find(id);
		dao.delete(turma);
		result.redirectTo(this).lista();
	}
}
